
const _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');

exports.__esModule = true;
exports.default = void 0;

const _extends2 = _interopRequireDefault(require('@babel/runtime/helpers/extends'));

const _utils = require('../../utils');

const _createNamespace = (0, _utils.createNamespace)('sku-row-prop-item');
const createComponent = _createNamespace[0];

const _default = createComponent({
  props: {
    skuValue: Object,
    skuKeyStr: String,
    skuEventBus: Object,
    selectedProp: Object,
    multiple: Boolean,
  },
  computed: {
    choosed: function choosed() {
      const { selectedProp } = this;
      const { skuKeyStr } = this;
      const { skuValue } = this;

      if (selectedProp && selectedProp[skuKeyStr]) {
        return selectedProp[skuKeyStr].indexOf(skuValue.id) > -1;
      }

      return false;
    },
  },
  methods: {
    onSelect: function onSelect() {
      this.skuEventBus.$emit('sku:propSelect', (0, _extends2.default)({}, this.skuValue, {
        skuKeyStr: this.skuKeyStr,
        multiple: this.multiple,
      }));
    },
  },
  render: function render() {
    const h = arguments[0];
    return h('span', {
      class: ['van-sku-row__item', {
        'van-sku-row__item--active': this.choosed,
      }],
      on: {
        click: this.onSelect,
      },
    }, [h('span', {
      class: 'van-sku-row__item-name',
    }, [this.skuValue.name])]);
  },
});

exports.default = _default;
